import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { BreadcrumbData } from 'src/app/components/my-breadcrumb/my-breadcrumb.component';
import { navInfos } from '../nav/nav-infos';

@Component({
  selector: 'app-base-form',
  templateUrl: './base-form.component.html',
  styleUrls: ['./base-form.component.scss']
})
export class BaseFormComponent implements OnInit {

  constructor(
    private route: ActivatedRoute
  ) { }

  ngOnInit(): void {
    this.pageInit()
  }

  breadcrumbData: BreadcrumbData[] = []
  bannerBg = ''
  pageInit(){
    this.route.queryParams.subscribe((res: any) => {
      const sortName = res.sortName
      const name = res.name
      this.bannerBg = `assets/images/banners/${sortName}banner.jpg`
      const routerUrl = navInfos.find(_ => _.sortName === sortName)?.router
      this.breadcrumbData = [
        { title: sortName, router: routerUrl ? routerUrl : '/home' },
        { title: name },
      ]
    })
  }

  uploadBack(fileIds: string){
    console.log(fileIds)
  }

}
